package com.liyingtao.servlet;

import com.liyingtao.bean.Admin;
import com.liyingtao.biz.AdminService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;


@WebServlet("/checkAdminNameServlet")
public class checkAdminNameServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String adminName=request.getParameter("adminName");
        AdminService adminservice= new AdminService();
        Admin admin=adminservice.checkName(adminName);
        PrintWriter out = response.getWriter();
        if(admin!=null){
            out.print("此用户名已经被注册");
        }else {
            out.print("此用户名可用");
        }

    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req, resp);
    }
}
